<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>地图定位</title>
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <!--
    用一下百度的定位 http://www.cnblogs.com/linguanh/p/4137865.html
    jsAPI  http://lbsyun.baidu.com/index.php?title=jspopular/guide/helloworld
  -->
</head>
<body>
<p id="adress"></p>
<script src="http://api.map.baidu.com/api?v=2.0&ak=MqafXCajblIp803b3nABMhOL0FxemAkS"></script>
<script>
  window.onload = function loand() {
    var ele = document.getElementById('adress');
    var geo = new BMap.Geolocation();

    geo.getCurrentPosition(function (res) {
      var lat = res.point.lat;
      var lng = res.point.lng;

      var point = new BMap.Point(lng, lat);
      var gc = new BMap.Geocoder();

      gc.getLocation(point, function (rs) {
        ele.innerHTML = JSON.stringify(rs);
      });
    });
  }
</script>
</body>
</html>